from sqlalchemy import create_engine,text,Column,Integer,String
from sqlalchemy.orm import declarative_base

#数据库的对象
HOST = '127.0.0.1'
PORT = 3306
DATABASE = 'itbz'
USER = 'root'
PWD = 'root'

DB_URI = f'mysql+pymysql://{USER}:{PWD}@{HOST}:{PORT}/{DATABASE}'

#创建引擎
engine = create_engine(DB_URI)
#创建一个基类
Base = declarative_base() 

class Person(Base):
    __tablename__ = 't_person'
    id = Column(Integer,primary_key=True,autoincrement=True)
    name = Column(String(32))
    age =Column(Integer)
    country = Column(String(32))

#映射表结构
Base.metadata.create_all(engine)

